package com.ts.ischool.utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class EncryptUtil {
	public static String MD5(String s) {
		try {
			MessageDigest md = MessageDigest.getInstance("MD5");
			byte[] md5 = md.digest(s.getBytes());
			StringBuffer sb = new StringBuffer();
			String part = null;
			for (int i = 0; i < md5.length; i++ ) {
				part = Integer.toHexString(md5[i] & 0xFF);
				if (part.length() == 1) {
					part = "0"+part;
				}
				sb.append(part);
			}
			return sb.toString();
			} catch (NoSuchAlgorithmException ex) {
				return s;
		}
	}
	
	public static void main(String args[]){
		String a = "3ecee6fe3ffea48c";
		String b = "ceacc56d3ecee6fe3ffea48c967c3641";
		
		String a1 = EncryptUtil.bin2hex(a);
		String a2 = EncryptUtil.bin2hex(b);
		
		java.math.BigInteger bi1 = new java.math.BigInteger (a1);
		java.math.BigInteger bi2 = new java.math.BigInteger (a2);
		
		java.math.BigInteger bi3 = bi1.multiply(bi2);
		
		Long l = bi3.longValue();
		String a4 = EncryptUtil.bin2hex(bi3.toString());
		System.out.println(a4);
		
		
	}
	
	public static String bin2hex(String bin) { 
        char[] digital = "0123456789ABCDEF".toCharArray(); 
        StringBuffer sb = new StringBuffer(""); 
        byte[] bs = bin.getBytes(); 
        int bit; 
        for (int i = 0; i < bs.length; i++) { 
            bit = (bs[i] & 0x0f0) >> 4; 
            sb.append(digital[bit]); 
            bit = bs[i] & 0x0f; 
            sb.append(digital[bit]); 
        } 
        return sb.toString(); 
    } 

}